clear all
set more off
set matsize 10000
tempfile ubigeo temp

local lista trust_police trust_army trust_church trust_newsp trust_rtv trust_parties trust_regi trust_jury trust_parliament trust_jne trust_onpe
local controls schooling male rural native married head 

use mergedp, clear

** LABELS
label var todoA "Army"
label var todoT "Terrorist"

recode trust_* (. = 0) if voted != .

******* Results
drop if vote_matter == .
local lista trust_police trust_army trust_church trust_parties trust_regi trust_jury trust_parliament trust_rtv trust_newsp

local r = 1
foreach var in `lista' {
	replace `var' = `var' * 100 
	reghdfe `var' todoA todoT `controls', abs(ubigeo1993 ubigeonac1993 i.ubigeo1993#i.ubigeonac1993 i.age i.year i.provid#c.trend) vce(cluster ubigeonac1993) keepsin
	est store reg`r'
	sum `var' if e(sample) == 1
	local y = r(mean)
	sum todoA if e(sample) == 1
	local sda = r(sd)
	sum todoT if e(sample) == 1
	local sdt = r(sd)
	local na`r' = (round(((_b[todoA]) * `sda') / `y', 0.0001)) * 100
	local nt`r' = (round(((_b[todoT]) * `sdt') / `y', 0.0001)) * 100
	local ++r
}

noisily estout reg* ///
using Table_8_0.tex, style(tex) c(b(fmt(2) star) se(par fmt(2))) ///
	label collabels(, none) eqlabels(none) mlabels(, none) varlabel(_cons " $ Control $ ") starlevel(* .1 ** .05 *** .01) ///
	keep(todoA todoT) ///
	order(todoA todoT) ///
	stats(r2 N N_clust, fmt(%9.2f %9.0g) labels(`"$ R ^{2}$"' "Observations" "Clusters")) replace 

texdoc init Table_8.tex, replace
tex \begin{table}[h]
tex \caption{Impact of armed conflict on voting, participation and democratic beliefs}
tex \label{tab:table1}
tex \begin{center}
tex \resizebox{16cm}{!}{
tex \begin{tabular}{lccccccccc} \hline \hline
tex \\
tex & Army & Police & Church & Parties & Region & Jury & Parliament & Radio & News outlets \\
tex \hline
tex \input{Table_8_0.tex}
tex &&&&&&&&& \\
tex \multicolumn{8}{l}{\textbf{Effect of 1 s.d. change in conflict measure as \% of mean of dependent variable:}} \\
tex Army & `na1' & `na2' & `na3' & `na4' & `na5' & `na6' & `na7' & `na8' & `na9' \\
tex Terrorist & `nt1' & `nt2' & `nt3' & `nt4' & `nt5' & `nt6' & `nt7' & `nt8' & `nt9' \\
tex &&&&&&&&& \\
tex \hline
tex \end{tabular}}
tex \end{center}
tex \end{table}	
	
